package cn.com.backstage.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import cn.com.api.entity.ApiU_circle_post;
import cn.com.api.service.ApiU_circle_postService;
import cn.com.backstage.controller.base.U_circle_postBaseController;

import cn.com.util.*;

@Controller
@RequestMapping(Utils.SYS_BACKSTAGE + "/")
public class U_circle_postController extends U_circle_postBaseController {

	private static Logger logger = Logger.getLogger(U_circle_postController.class);

	@Autowired
	private ApiU_circle_postService apiU_circle_postService;

	/**
	 * 列表
	 * 
	 * @return
	 */
	@RequestMapping(value = "circlepostlist")
	public ModelAndView u_circle_post_list(HttpServletRequest request, HttpServletResponse response, PageInfo pageInfo)
			throws Exception {
		ModelAndView mv = new ModelAndView("forward:/backstage/u_circle_post_list.jsp");
		Map<String, Object> map = new HashMap<String, Object>();
		String circleid = request.getParameter("circleid");
		String circle_name = request.getParameter("circle_name");
		String usernickname = request.getParameter("usernickname");
		if (circleid != null && !"".equals(circleid)) {
			map.put("circle_id", circleid);
		}
		if (circle_name != null && !"".equals(circle_name)) {
			map.put("circle_name", circle_name);
		}
		if (usernickname != null && !"".equals(usernickname)) {
			map.put("usernickname", usernickname);
		}
		List<ApiU_circle_post> u_circle_posts = apiU_circle_postService.findU_circle_postList(map, pageInfo);
		mv.addObject("u_circle_posts", u_circle_posts);
		mv.addObject("pageInfo", pageInfo);
		mv.addObject("paramMap", map);
		return mv;
	}

	/**
	 * 帖子详情
	 * 
	 * @return
	 */
	@RequestMapping(value = "circlepostshow")
	public ModelAndView circlepostshow(HttpServletRequest request, HttpServletResponse response, PageInfo pageInfo)
			throws Exception {
		ModelAndView mv = new ModelAndView("forward:/backstage/u_circle_post_show.jsp");
		String circlepostid = request.getParameter("circlepostid");
		if (circlepostid != null && !"".equals(circlepostid)) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("id", circlepostid);
			ApiU_circle_post u_circle_post = apiU_circle_postService.findU_circle_postsByMap(map);
			mv.addObject("u_circle_post", u_circle_post);
		}
		return mv;
	}

	/**
	 * 帖子回复信息
	 * 
	 * @return
	 */
	@RequestMapping(value = "circlepostreplyshow")
	public ModelAndView circlepostreplyshow(HttpServletRequest request, HttpServletResponse response, PageInfo pageInfo)
			throws Exception {
		ModelAndView mv = new ModelAndView("forward:/backstage/circlepostreplyshow.jsp");
		String circlepostid = request.getParameter("circlepostid");
		if (circlepostid != null && !"".equals(circlepostid)) {
			Map<String, Object> map = new HashMap<String, Object>();
			map.put("id", circlepostid);
			ApiU_circle_post u_circle_post = apiU_circle_postService.findU_circle_postsByMap(map);
			mv.addObject("u_circle_post", u_circle_post);
		}
		return mv;
	}

}
